﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GISCore.Geometry.IO;

namespace GISCore.Geometry.Intersectors
{
    class SweepLineIITester
    {
        private List<Line> readFiles(String filename1, String filename2)
        {
            List<Line> lines = new List<Line>();
            IFileHandler handler_base = new GMLFileHandler(Constants.baseLayerId);
            IFileHandler handler_target = new GMLFileHandler(Constants.targetLayerId);
            Layer layer_base = handler_base.Read(filename1);
            Layer layer_target = handler_target.Read(filename2);
            foreach (var p in layer_base.GetPolygons())
            {
                foreach (var l in p.getLines())
                {
                    lines.Add(l);
                }
                foreach (var h in p.holes)
                {
                    foreach (var hl in h.getLines())
                    {
                        lines.Add(hl);
                    }
                }
            }
            foreach (var p in layer_target.GetPolygons())
            {
                foreach (var l in p.getLines())
                {
                    lines.Add(l);
                }
                foreach (var h in p.holes)
                {
                    foreach (var hl in h.getLines())
                    {
                        lines.Add(hl);
                    }
                }
            }
            return lines;

        }
        public void tester()
        {
            TestParallelData1();
        }
        public void TestRegularData()
        {
            List<Line> lines;
            string filename1 = "../../../GISUnitTests/Test Data/layerA.gml";
            string filename2 = "../../../GISUnitTests/Test Data/layerB.gml";
            lines = readFiles(filename1, filename2);
            SweepLineII sl = new SweepLineII();
            sl.Intersect(lines);
        }
        public void TestParallelData()
        {
            List<Line> lines;
            string filename1 = "../../../GISUnitTests/Test Data/layerA_parallel1.gml";
            string filename2 = "../../../GISUnitTests/Test Data/layerB_parallel1.gml";
            lines = readFiles(filename1, filename2);
            SweepLineII sl = new SweepLineII();
            sl.Intersect(lines);
        }
        public void TestParallelData1()
        {
            List<Line> lines;
            string filename1 = "../../../GISUnitTests/Test Data/layerA_parallel2.gml";
            string filename2 = "../../../GISUnitTests/Test Data/layerB_parallel2.gml";
            lines = readFiles(filename1, filename2);
            SweepLineII sl = new SweepLineII();
            sl.Intersect(lines);
        }
    }
}
